Skip to content

Migrate translator to shared synchronous primitive - #530

Open
bit-aloo wants to merge 4 commits into
stratum-mining:mainfrom
bit-aloo:2026-05-26-migrate-translator-to-shared-map
Open

Migrate translator to shared synchronous primitive#530
bit-aloo wants to merge 4 commits into
stratum-mining:mainfrom
bit-aloo:2026-05-26-migrate-translator-to-shared-map

Conversation

@bit-aloo

@bit-aloo bit-aloo commented May 26, 2026

Copy link
Copy Markdown
Member

closes: #601

@bit-aloo
bit-aloo force-pushed the 2026-05-26-migrate-translator-to-shared-map branch 3 times, most recently from f086369 to 4f9d12a Compare May 27, 2026 12:28
Comment on lines +200 to +201
.with(|data| data.authorized_worker_name == *name)
.unwrap();

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't propagate error from Sv1Server downstream message handler, considering it doesn't support TproxyError type.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved forward with UnknownId variant for now, we can extend error enum in Sv1 crate later to include some poison related variant.

@bit-aloo
bit-aloo force-pushed the 2026-05-26-migrate-translator-to-shared-map branch from 4f9d12a to 26c7b24 Compare May 27, 2026 12:56
@bit-aloo
bit-aloo force-pushed the 2026-05-26-migrate-translator-to-shared-map branch 2 times, most recently from cd0fdd1 to 2ec31b8 Compare July 21, 2026 12:27
@bit-aloo
bit-aloo marked this pull request as ready for review July 21, 2026 16:30
@GitGab19

Copy link
Copy Markdown
Member

Is this aiming to close #601?

@bit-aloo

Copy link
Copy Markdown
Member Author

Is this aiming to close #601?

yup updated the description

@GitGab19

Copy link
Copy Markdown
Member

Can you solve conflicts?

@bit-aloo
bit-aloo force-pushed the 2026-05-26-migrate-translator-to-shared-map branch from a8e04fe to dcb1833 Compare July 28, 2026 15:16
@bit-aloo

Copy link
Copy Markdown
Member Author

Can you solve conflicts?

Should be good now

@GitGab19

Copy link
Copy Markdown
Member

Preliminary clanker findings:

## Issues

| # | Severity | Finding |
|---|----------|---------|
| 1 | 🔴 High | `difficulty_manager.rs`: a failed `set_difficulty` send to **one** downstream is now `TproxyError::shutdown` → cancels the global token → **whole proxy exits**. Trigger is a routine race: miner disconnects between sender clone and `send().await`. Was log-and-continue before. |
| 2 | 🔴 High | Per-downstream `hash_rate_to_target` failures (3 sites) and `try_vardiff` errors now also escalate to global shutdown; previously `continue`/ignored. One pathological miner can take down the proxy. |
| 3 | 🟡 Medium | `vardiff_future` select branch: if `handle_error_action` ever returns `Continue`, the completed future is re-polled → panic. Currently unreachable only because all escaping errors are shutdown-kind and `biased;` breaks first on cancelled tokens. Set `vardiff_enabled = false` after an error. |
| 4 | 🟢 Low | Keepalive path: `get_mut` → `with_mut_or_default` can re-create a `valid_sv1_jobs` entry for a dead channel (never cleaned up → small leak). Use `with_mut`. |
| 5 | ⚪ Nit | `Error::UnexpectedMessage("poisoned downstream data lock")` misuses a protocol error variant (×8 — extract a helper); `contains_key` + `with_mut` TOCTOU pairs in `mining_message_handler.rs` (benign today, fragile); `handle_downstream_message` now does 3–4 map lookups per SV1 message; vardiff iteration holds shard *write* guards during computation (cheap, no awaits — acceptable). |

@bit-aloo
bit-aloo force-pushed the 2026-05-26-migrate-translator-to-shared-map branch from dcb1833 to 9e1e153 Compare July 28, 2026 16:48
@bit-aloo
bit-aloo force-pushed the 2026-05-26-migrate-translator-to-shared-map branch from 043ddf7 to 2f6c38b Compare July 29, 2026 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor tProxy to reduce nested locking

2 participants